<script setup>
    // 引入水球图拓展插件
    import 'echarts-liquidfill'
    import * as echarts from 'echarts';
    import { ref, onMounted } from 'vue';
    let people = ref('666666人');
    let percentage = ref(people.value.replace('人', '') / 999999);
    //获取节点
    let charts = ref();
    onMounted(() => {
        //获取echarts类的实例
        let mycharts = echarts.init(charts.value);
        //设置实例的配置项
        mycharts.setOption({
            //标题组件
            title: {
                text: ''
            },
            //x|y轴组件
            xAxis: {},
            yAxis: {},
            //系列:决定你展示什么样的图形图标
            series: {
                type: 'liquidFill',//系列
                data: [percentage.value],//展示的数据
                waveAnimation: true,//动画
                animationDuration: 3,
                animationDurationUpdate: 0,
                radius: '80%',//半径
                outline: {//外层边框颜色设置
                    show: true,
                    borderDistance: 8,
                    itemStyle: {
                        color: 'skyblue',
                        borderColor: '#294D99',
                        borderWidth: 8,
                        shadowBlur: 20,
                        shadowColor: 'rgba(0, 0, 0, 0.25)'
                    }
                },
            },
            //布局组件
            grid: {
                left: 0,
                right: 0,
                top: 0,
                bottom: 0
            }

        })
    })
</script>
<template>
    <div class="box">
        <div class="top">
            <div class="top-left">
                <p class="title">实时游客统计</p>
                <img
                    src="../../images/dataScreen-title.png"
                    alt=""
                >
            </div>
            <div class="top-right">
                <p>可预约总量&nbsp;<span>99999</span>&nbsp;人</p>
            </div>
        </div>
        <div class="number">
            <span
                v-for="(item, index) in people"
                :key="index"
            >{{ item }}</span>
        </div>
        <!-- 盒子将来echarts展示图形图标的节点 -->
        <div
            class="charts"
            ref="charts"
        ></div>
    </div>
</template>
<style scoped>
    .box {
        background: url(../../images/dataScreen-main-lb.png) no-repeat;
        background-size: 100% 100%;
        margin-top: 10px;
    }

    .top {
        height: 70px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .top-left {
        margin-left: 20px;
    }

    .top-left .title {
        color: white;
        font-size: 20px;
    }

    .top-left img {
        margin-top: 10px;
    }

    .top-right {
        margin-right: 20px;
    }

    .top-right p {
        color: white;
        font-size: 20px;
    }

    .top-right p span {
        color: red;
    }

    .number {
        display: flex;
    }

    .number span {
        flex: 1;
        height: 40px;
        text-align: center;
        font-size: 20px;
        line-height: 40px;
        background: url(../../images/total.png) no-repeat;
        background-size: 100% 100%;
        color: #29fcff;
    }

    .charts {
        width: 100%;
        height: 250px;
    }
</style>